package com.sky.controller.user;

import com.sky.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;

/**
 * 用户端 - 店铺管理
 */
@RestController("userShopController")
@RequestMapping("/user/shop")
@Slf4j
@Api(tags = "店铺管理")
public class ShopController {
    @Autowired
    private RedisTemplate redisTemplate;
    private static final String SHOP_STATUS_KEY = "SHOP_STATUS";

    @GetMapping("/status")
    @ApiOperation("查询店铺营业状态")
    public Result<Integer> queryShopStatus() {
        Integer status = (Integer)redisTemplate.opsForValue().get(SHOP_STATUS_KEY);
        log.info("查询店铺当前营业状态：{}", status == 0 ? "打烊中" : "营业中");
        return Result.success(status);
    }
}
